<?php
/**
 * Author:Arthur
 * Date:2013-5-31
 * File Name:credit_card_table.php
 * Email:kingarthurx@sina.cn
 */
$sql="select * from zy_card_info where user_id='".yii::app()->user->id."'";
$cardInfo=Yii::app()->db->createCommand($sql)->queryAll();
if(!empty($cardInfo)){
?>
<div id="card-info-grid" class="grid-view" style="display: block;">
<table class="responsive table table-striped table-bordered">
<thead>
<tr>
<th style="width:15%" id="card-info-grid_c0"><a class="sort-link" href="#"><?php echo Yii::t('base','Payment Method')?></a></th><th style="width:20%" id="card-info-grid_c1"><a class="sort-link" href="#"><?php echo Yii::t('base','Card Number')?></a></th><th style="width:15%" id="card-info-grid_c2"><a class="sort-link" href="#"><?php echo Yii::t('base','Name on Card')?></a></th><th style="width:15%" id="card-info-grid_c3"><a class="sort-link" href="#"><?php echo Yii::t('base','Expiry Date')?></a></th><th style="width:60%" id="card-info-grid_c4"><?php echo Yii::t('base','Operate')?></th></tr>
</thead>
<tbody>
<tr class="odd selected">
<td><?php echo CardInfo::model()->paymentMethodName($cardInfo[0]['card_type']);?></td><td><?php if(strlen($cardInfo[0]['card_number']) == 16){echo substr_replace($cardInfo[0]['card_number'], '********', 4, 8);}?></td><td><?php echo $cardInfo[0]['name'];?></td><td><?php echo $cardInfo[0]['expirydate'];?></td><td class="button-column">
<?PHP if($_GET['flag'] == '3G'){?>
<a class="btn btn-small new" title="New Card" href="#" onclick="vistaShow();"><?php echo Yii::t('base','New Card')?></a>
<a class="btn btn-small old" title="Old Card" href="#" onclick="vistaHide();"><?php echo Yii::t('base','Old Card')?></a>
<?php }else{?>
<a class="btn btn-inverse btn-small" title="Delete" href="<?php echo Yii::app()->createUrl("cardInfo/delete/".$cardInfo[0]['card_info_id']); ?>" >Delete</a>
<?php } ?>
</td>
</tr>
</tbody>
</table>
</div>
<?php } ?>
<script type="text/javascript" >
	function vistaShow(){
		$("#prompt").show();
		$("#vista").show();
	}
	function vistaHide(){
		$("#prompt").hide();
		$("#vista").hide();
	}
	
</script>